package com.jooink.experiments.elementalgetusermedia.client;


public class ElementalUtils {
	
	public final native static com.google.gwt.dom.client.Element castElementToElement(elemental.dom.Element e) /*-{
		return e;
	}-*/;

	
	public interface UserMediaCallback {
		public void onSuccess(String url);
		public void onFail();
	}

	public native static boolean getUserVideo(UserMediaCallback callback) /*-{
  	  if(navigator.webkitGetUserMedia) {
      	navigator.webkitGetUserMedia(
      	{video: true, toString: function() {return "video";}}, 
      	function(stream) {
			var s = window.URL.createObjectURL(stream);
				$entry(callback.@com.jooink.experiments.elementalgetusermedia.client.ElementalUtils.UserMediaCallback::onSuccess(Ljava/lang/String;)(s));
			}, 
			function() { 
				$entry(callback.@com.jooink.experiments.elementalgetusermedia.client.ElementalUtils.UserMediaCallback::onFail()());
			});
			return true;
	} else {
		return false;
	}
   }-*/;
	
}
